package fr.lostnet.mapview;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ToggleButton;

public class MapView extends Activity implements OnClickListener  {
	
	private static GpsLocation location_;
	
	/** Called when the activity is first created */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /* initialize the map location manager */
        location_ = new GpsLocation(this);
        /* initialize GPS button */
        ToggleButton gpsTb = (ToggleButton) findViewById(R.id.gpsButton);
        gpsTb.setChecked(location_.isEnabled());
        gpsTb.setOnClickListener(this);
    }
	
	/** Called when the activity is started or resumed */
	@Override
	protected void onResume() {
		location_.startGps();
		super.onResume();
	}
	
	/** Called when the activity is stopped or paused */
	@Override
	protected void onPause() {
		location_.stopGps();
		super.onPause();
	}
	
	@Override
	public void onClick(View v) {
		Intent gpsOptionsIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);  
        startActivity(gpsOptionsIntent);
        GoogleMap gm = new GoogleMap();
        gm.test();
	}

}